<?php
/**
 * 展示模型 
 * @author diccn 
 * @version TS3.0
 */
class WorksModel extends Model {
	
	/**
	 * 获取喜欢的作品
	 * 
	 * @author diccn
	 * 2014-9-15
	 */
	public function getLikeWorks($uid){
		return $this->field("w.*")->join("as w RIGHT JOIN `{$this->tablePrefix}like` as l ON w.id = l.wid" )
			->where("l.uid = {$uid}")->findPage();
	}
	/**
	 * 获取热门作品
	 * 
	 * @author diccn
	 * 2014-9-27
	 */
	public function getHostWorks($tab){
		$order = $tab === 'new' ? 'ctime DESC' :'comments_total DESC';
		return $this->order($order)->findPage();
	}
	/**
	 * 获取用户数最新3条作品
	 * 
	 * @author diccn
	 * 2014-10-13
	 */
	public function getUserNew3($uid){
		return $this->field("id,uid,title,cover,ctime")->where("uid = {$uid}")->order("ctime DESC")->limit("3")->findAll();
	}
}